/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.ukni.persistence.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author eurico
 */
@Entity
@Table(name = "IMAGE")
@NamedQueries({@NamedQuery(name = "Image.findAll", query = "SELECT i FROM Image i"), @NamedQuery(name = "Image.findByIdimage", query = "SELECT i FROM Image i WHERE i.idimage = :idimage"), @NamedQuery(name = "Image.findByName", query = "SELECT i FROM Image i WHERE i.name = :name"), @NamedQuery(name = "Image.findByDescription", query = "SELECT i FROM Image i WHERE i.description = :description"), @NamedQuery(name = "Image.findByUri", query = "SELECT i FROM Image i WHERE i.uri = :uri"), @NamedQuery(name = "Image.findByDatecreation", query = "SELECT i FROM Image i WHERE i.datecreation = :datecreation")})
public class Image implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "IDIMAGE")
    private Integer idimage;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @Column(name = "DESCRIPTION")
    private String description;
    @Basic(optional = false)
    @Column(name = "URI")
    private String uri;
    @Basic(optional = false)
    @Column(name = "DATECREATION")
    @Temporal(TemporalType.DATE)
    private Date datecreation;
    @JoinColumn(name = "REFIDBAND", referencedColumnName = "IDBAND")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Band refidband;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "image", fetch = FetchType.EAGER)
    private Set<CommentImage> commentImageCollection;

    public Image() {
    }

    public Image(Integer idimage) {
        this.idimage = idimage;
    }

    public Image(Integer idimage, String name, String description, String uri, Date datecreation) {
        this.idimage = idimage;
        this.name = name;
        this.description = description;
        this.uri = uri;
        this.datecreation = datecreation;
    }

    public Integer getIdimage() {
        return idimage;
    }

    public void setIdimage(Integer idimage) {
        this.idimage = idimage;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public Date getDatecreation() {
        return datecreation;
    }

    public void setDatecreation(Date datecreation) {
        this.datecreation = datecreation;
    }

    public Band getRefidband() {
        return refidband;
    }

    public void setRefidband(Band refidband) {
        this.refidband = refidband;
    }

    public Set<CommentImage> getCommentImageCollection() {
        return commentImageCollection;
    }

    public void setCommentImageCollection(Set<CommentImage> commentImageCollection) {
        this.commentImageCollection = commentImageCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idimage != null ? idimage.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Image)) {
            return false;
        }
        Image other = (Image) object;
        if ((this.idimage == null && other.idimage != null) || (this.idimage != null && !this.idimage.equals(other.idimage))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "deti.es.ukni.persistence.entity.Image[idimage=" + idimage + "]";
    }

}
